package com.pdg.mcplugin.simpleconomy.dataproviders.accounts;

import com.pdg.mcplugin.common.baseclasses.DataProviderBase;
import com.pdg.mcplugin.common.interfaces.TableProviderKey;

public class AccountKey implements TableProviderKey{
	public static final String FIELD_NAME = "name";
	private static final String CREATE_FIELDS = "`"+FIELD_NAME+"` TEXT NOT NULL";
	private static final String INSERT_FIELDS = "`"+FIELD_NAME+"`";
	private static final String INSERT_VALUES = "'%s'";
	private static final String DEFAULT_NAME = "";
	private static final String WHERE_CLAUSE = "`"+FIELD_NAME+"`='%s'";
	private String name;
	
	public AccountKey(String theName){
		setName(theName);
	}

	@Override
	public String getCreateFields() {
		return CREATE_FIELDS;
	}

	@Override
	public String getInsertFields() {
		return INSERT_FIELDS;
	}

	@Override
	public String getInsertValues() {
		return String.format(INSERT_VALUES, DataProviderBase.sqlSafeString(getName()));
	}

	@Override
	public String getWhereClause() {
		return String.format(WHERE_CLAUSE, DataProviderBase.sqlSafeString(getName()));
	}
	public static AccountKey defaultInstance(){
		return new AccountKey(DEFAULT_NAME);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
